<template>
    <el-dialog :title="title" :visible.sync="visible" width="500px" append-to-body>
        <el-form ref="form" :model="formdata" :rules="rules" label-width="110px">
            <el-form-item label="审批状态" prop="approveStatus">
                <el-radio v-for="item in dict.type.league_approve_status" :key="item.value" v-model="formdata.approveStatus" :label="item.value">{{item.label}}</el-radio>
            </el-form-item>  
            <el-form-item label="审批备注" prop="approveRemark">
                <el-input placeholder="请输入审批备注" v-model="formdata.approveRemark"/>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitForm">确 定</el-button>
            <el-button @click="visible = false">取 消</el-button>
        </div>
    </el-dialog>
    </template>
    
    <script>
    import { 
        addActivity,
        editActivity
    } from "@/api/leagueManagement/activity";
    export default {
        name: 'activityEdit',
        data () {
            return {
                title: '审批',
                visible: false,
                formdata: {
                    approveStatus: '',
                    approveRemark: ''
                },
                rules: {
                    approveStatus: [
                        { required: true, message: '请选择审批状态', trigger: 'change' }
                    ]
                },
                rowdata:{}
            }
        },
        dicts: [
            "league_approve_status"
        ],
        props: {
            mainType:{
                type: Number,
                default: 1
            }  
        },
        methods: {
            open (rowdata) {
                this.visible = true
                this.formdata = {
                    approveStatus: '',
                    approveRemark: ''
                }
                if (rowdata) {
                    this.rowdata = rowdata
                }
            },
            submitForm () {
                this.$refs["form"].validate(valid => {
                    if (valid) {
                        if (this.rowdata.id != undefined) {
                            editActivity({
                                ...this.rowdata,
                                ...this.formdata,
                                mainType: this.mainType
                            }).then(response => {
                                this.$modal.msgSuccess("审批完成");
                                this.visible = false;
                                this.$emit('updateList');
                            });
                        }
                    }
                });
            }
        }
    
    }
    </script>
    
    <style lang="scss" scoped>
    
    </style>